#include <stdio.h>
#include <stdlib.h>
#include "list.h"
#include <string.h>
#include "book.h"
#include <unistd.h>
void start(LinkedList* list,FILE *f)
{
    fseek(f,0,SEEK_SET);
    char header[100];
    fgets(header,sizeof(header),f);

    int num;
    char name[50] = {0};
    char writer[50] = {0} ;
    while(fscanf(f,"%d %s %s",&num,name,writer)==3)
    {   
        insert_head_doublelist(list,num,name,writer);
    }//遍历文件，读取文本所有信息
    fprintf(f,"\n");
    fflush(f);
}//这是最开始的状态

void steam(LinkedList* list,FILE *f)
{   
    while(1)
    {
        int i;
        printf("欢迎使用图书管理系统，请输入你的要求：\n");
        printf("1.增加图书\n");
        printf("2.查找图书\n");
        printf("3.借书\n");
        printf("4.还书\n");
        printf("5.修改图书信息\n");
        printf("6.删除图书\n");
        printf("7.查看目前的书本\n");
        printf("8.退出\n");
        scanf("%d",&i);
        printf("加载中....请稍后...\n");
        sleep(3);
        switch (i)
        {
        case 1:
            add_book(list,f);
            break;
        case 2:
            find_book(list,f);
            break;
        case 3:
            borrow_book(list,f);
            break;
        case 4:
            ret_book(list,f);
            break;
        case 5:
            modify_book(list,f);
            break;
        case 6:
            delete_book(list,f);
            break;
        case 7:
            look_book(list,f);
            break;
        case 8:
            printf("感谢你的使用！\n");
            goto end;
        }
        sleep(3);

    }

end:
    freeList(list);
    fclose(f);
}



